/*----------------------------------------------------------------------
  - File name      : STC8Ax_SPI.h
  - Author         : Quark Team
  - Update date    : 2020-12-09
  -	Copyright      : Gevico Electronic studio
  - Module comments: Header file of SPI module.
-----------------------------------------------------------------------*/
#ifndef __STC8Ax_SPI_H_
#define __STC8Ax_SPI_H_
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/
/*--------------------------------------------------------
| @Description: STC8Ax Options                           |
--------------------------------------------------------*/
#include "STC8Ax_REG.h"   
/*--------------------------------------------------------
| @Description: STC8Ax core                              |
--------------------------------------------------------*/
#include "STC8Ax_CORE.h"
/*-----------------------------------------------------------------------
|                                 DATA                                  |
-----------------------------------------------------------------------*/

/*--------------------------------------------------------
| @Description: SPI type control enum                    |
--------------------------------------------------------*/

typedef enum
{
  SPI_Type_Master = 0x90,
  SPI_Type_Slave  = 0x80,
  SPI_Type_Master_Slave = 0x00 
} SPIType_Type;

/*--------------------------------------------------------
| @Description: SPI clock source select enum             |
--------------------------------------------------------*/

typedef enum
{
  SPI_SCLK_DIV_4  = 0x00,
  SPI_SCLK_DIV_8  = 0x01,
  SPI_SCLK_DIV_16 = 0x02,
  SPI_SCLK_DIV_32 = 0x03
} SPIClkSrc_Type;

/*--------------------------------------------------------
| @Description: SPI Transmission sequence enum           |
--------------------------------------------------------*/

typedef enum
{
  SPI_Tran_MSB = 0x00,
  SPI_Tran_LSB  = 0x01
} SPITran_Type;

/*--------------------------------------------------------
| @Description: SPI mode control enum                    |
--------------------------------------------------------*/

typedef enum
{
  SPI_Mode_0  = 0x00,
  SPI_Mode_1  = 0x01,
  SPI_Mode_2  = 0x02,
  SPI_Mode_3  = 0x03
} SPIMode_Type;

/*--------------------------------------------------------
| @Description: SPI init structure                       |
--------------------------------------------------------*/

typedef struct 
{
  SPIType_Type Type;
  SPIClkSrc_Type ClkSrc;
  SPIMode_Type Mode;
  SPITran_Type Tran;
  FUNSTATE Run;
} SPIInit_Type;

/*-----------------------------------------------------------------------
|                             API FUNCTION                              |
-----------------------------------------------------------------------*/

FSCSTATE SPI_Init(SPIInit_Type *SPIx);
FSCSTATE SPI_Send_Data(uint8 Dat);
FSCSTATE SPI_Rev_Data(uint8 * Dat);

#endif
/*-----------------------------------------------------------------------
|          END OF FLIE        (C) COPYRIGHT Gevico Electronics          | 
-----------------------------------------------------------------------*/

